"""
model name : 深度学习
file       : Test.py
information:
    author : OuYang
    time   : 2025/1/15
"""

import cv2
import numpy as np


def show_image(winname, image):
    cv2.imshow(winname, image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


# 绘制矩形
def draw_rectangle(frame, point1, point2, imgsz=448, color=(0, 255, 0), thickness=1, show=False, winname="frame"):
    if frame is None:
        imgsz = 448
        frame = np.zeros((imgsz, imgsz, 3), dtype=np.uint8)
    x1, y1 = point1
    x2, y2 = point2

    cv2.rectangle(frame, (int(x1 * imgsz), int(y1 * imgsz)), (int(x2 * imgsz), int(y2 * imgsz)), color, thickness)
    if show is True:
        show_image(winname, frame)
    return frame
